package hn.cch.flink;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.expressions.Expression;
import org.apache.flink.table.expressions.ExpressionVisitor;

import java.util.Collections;
import java.util.List;

import static org.apache.flink.table.api.Expressions.$;

public class FlinkSQL {

    public static void main(String[] args) {
        EnvironmentSettings settings = EnvironmentSettings
            .newInstance()
            .inStreamingMode()
            .build();


        TableEnvironment env = TableEnvironment.create(settings);

        String sql = "";
        TableResult tableResult = env.executeSql(sql);

        String selectScript = "";
        Table table = env.sqlQuery(selectScript);


        Expression expression = new Expression() {
            @Override
            public String asSummaryString() {
                return "";
            }

            @Override
            public List<Expression> getChildren() {
                return Collections.emptyList();
            }

            @Override
            public <R> R accept(ExpressionVisitor<R> expressionVisitor) {
                return null;
            }
        };
        env.from("table_name").where(expression).select();


        // DataSet<Row> result = environment
        //     .from("Orders")
        //     .groupBy($("a"))
        //     .select($("a"), $("b").count().as("cnt"))
        //     .toDataSet(counts, Row.class);
        //
        // result.print();
    }

}
